package com.jxdinfo.hussar.cloud.module.example.lift.controller;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jxdinfo.hussar.cloud.module.example.lift.model.LiftDataAlarm;
import com.jxdinfo.hussar.cloud.module.example.lift.service.LiftDataAlarmService;
import com.jxdinfo.hussar.platform.core.base.apiresult.ApiResponse;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * 升降机报警数据(LiftDataAlarm)表控制层
 *
 * @author makejava
 * @since 2023-10-23 18:06:35
 */
@RestController
@RequestMapping("liftDataAlarm")
public class LiftDataAlarmController  {
    /**
     * 服务对象
     */
    @Resource
    private LiftDataAlarmService liftDataAlarmService;

    /**
     * 分页查询所有数据
     *
     * @param page 分页对象
     * @param liftDataAlarm 查询实体
     * @return 所有数据
     */
    @GetMapping
    public ApiResponse selectAll(Page<LiftDataAlarm> page, LiftDataAlarm liftDataAlarm) {
        return ApiResponse.success(this.liftDataAlarmService.page(page, new QueryWrapper<>(liftDataAlarm)));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ApiResponse selectOne(@PathVariable Serializable id) {
        return ApiResponse.success(this.liftDataAlarmService.getById(id));
    }

    /**
     * 新增数据
     *
     * @param liftDataAlarm 实体对象
     * @return 新增结果
     */
    @PostMapping
    public ApiResponse insert(@RequestBody LiftDataAlarm liftDataAlarm) {
        return ApiResponse.success(this.liftDataAlarmService.save(liftDataAlarm));
    }

    /**
     * 修改数据
     *
     * @param liftDataAlarm 实体对象
     * @return 修改结果
     */
    @PutMapping
    public ApiResponse update(@RequestBody LiftDataAlarm liftDataAlarm) {
        return ApiResponse.success(this.liftDataAlarmService.updateById(liftDataAlarm));
    }

    /**
     * 删除数据
     *
     * @param idList 主键结合
     * @return 删除结果
     */
    @DeleteMapping
    public ApiResponse delete(@RequestParam("idList") List<Long> idList) {
        return ApiResponse.success(this.liftDataAlarmService.removeByIds(idList));
    }
}

